/**
 * Created by CaoShi at 2021/2/11 6:56.
 */

#include "Demo.h"

Demo::Demo() {
    this->data = 1;
    cout << "无参构造" << endl;
}

Demo::Demo(int data) {
    this->data = data;
    cout << "有参构造" << endl;
}

Demo::Demo(const Demo &obj) {
    this->data = obj.data;
    cout << "拷贝构造函数" << endl;
}

Demo::~Demo() {
    cout << "析构函数" << endl;
}


// const修饰类的成员函数, 目的是让编译器知道这个成员函数内部不可操作成员变量
void Demo::myPrintData() const {
    // this->data = 10000;  非法操作
    // mutable修饰的成员变量在const函数中可以修改
    this->num = 100000;
    cout << this->data << endl;
}



